﻿using TCommon;
using TCommunication.Model;

namespace TCommunication.Interface;
/// <summary>
/// Can通道
/// </summary>
public interface ICanChannel:IDisposable
{
    /// <summary>
    /// 是否开启
    /// </summary>
    public bool IsOpen { get; }
    /// <summary>
    /// 打开通道
    /// </summary>
    /// <returns></returns>
    public OperateResult Open();
    /// <summary>
    /// 关闭通道
    /// </summary>
    /// <returns></returns>
    public OperateResult Close();
    /// <summary>
    /// 发送Can帧
    /// </summary>
    /// <param name="frame">Can帧</param>
    /// <returns>发送结果</returns>
    public OperateResult Send(CanFrame frame);

    /// <summary>
    /// 根据Id读取Can帧
    /// </summary>
    /// <param name="receivedInfo"><see cref="CanReceivedInfo"/>读取信息</param>
    /// <param name="timeOut">超时时间</param>
    /// <returns>读取的<see cref="CanFrame"/></returns>
    public OperateResult<CanFrame> Read(CanReceivedInfo receivedInfo, int timeOut = 5000);
}